================================================================================
REPLICATION INSTRUCTIONS
================================================================================

These files (data and R code) are designed to replicate the study 
"Who would defend Kinmen and Matsu (and what is Wuchiu?): 
Taiwanese public opinion on outlying islands".

Please run the code in the "CFL_results.R" file to replicate Figure 3-12.

The analysis was conducted using R version 4.3.3.


================================================================================
FILE STRUCTURE
================================================================================

DATA FILES:
- df2023.rda : 2023 survey data (N = 1,541)
- df2024.rda : 2024 survey and experiment data (N = 1,403)

R CODE FILES:
- CFL_results.R : Main replication script (Figures 3-12)

OUTPUT FIGURES (Generated by the analysis):
- fig3.png   : 2023 survey mean approval of defending four islands
- fig4.png   : 2024 survey mean binary agreement, belong / security
- fig5.png   : Experiment ATE of territory (Wuchiu / Matsu vs. Taiwan)
- fig6.png   : Experiment ATE of attack type (Seizure vs. Blockade)
- fig7.png   : Experiment predicted means by 2x3 treatment cell
- fig8.png   : 2023 survey subgroup means (6-panel)
- fig9.png   : Experiment predicted approval by identity (Taiwanese vs. Dual/Chinese)
- fig10.png  : 2024 survey belong vs. security by identity (Taiwanese vs. Dual/Chinese)
- fig11.png  : Experiment predicted approval by identity2 (Chinese vs. Dual/Taiwanese)
- fig12.png  : 2024 survey belong to Taiwan only by identity2 (Chinese vs. Dual/Taiwanese)


================================================================================
REQUIRED R PACKAGES
================================================================================

The following R packages are required:
- tidyverse
- estimatr
- marginaleffects
- patchwork
- Rmisc


================================================================================
HOW TO RUN
================================================================================

Step 1. Set the working directory to the folder containing these files:
        setwd("path to your folder")
Step 2. Run the analysis: "CFL_results.R"


================================================================================
DATA VARIABLE REFERENCE
================================================================================

df2023 (2023 survey):
  Key DVs  : Taiping, Kinmen, Penghu, Matsu (0-10, approval of defending)
  Subgroups: gender (Female / Male)
             age    (Young 49- / Old 50+)
             edu    (College and above / High school and below)
             identity (Taiwanese / Dual/Chinese)
             party  (KMT / DPP / TPP)
             tondu  (Independence / Status Quo / Unification)

df2024 (2024 survey + experiment):
  Belonging / Security :
    belong_1:6 / security_1:6
    Suffix mapping: 1=Kinmen, 2=Matsu, 3=Wuchiu, 4=Taiping, 5=Pratas, 6=Penghu
  Experiment DV        : exp_defend (1-5, strongly disagree to strongly agree)
  Experiment treatment :
    exp_t1 (Blockade / Seizure,        base: Blockade)
    exp_t2 (Taiwan / Wuchiu / Matsu,   base: Taiwan)
  Identity variables   :
    identity  (Taiwanese / Dual/Chinese)
    identity2 (Dual/Taiwanese / Chinese)
    identity3 (Taiwanese / Dual / Chinese)
  Subgroups: gender, age, edu, party, tondu (same coding as df2023)

Derived objects (constructed at the top of CFL_results.R):
  df2023_long : long format of df2023
                cols: island (Penghu/Kinmen/Matsu/Taiping), defending (0-10)
  df2024_long : long format of df2024 belonging/security battery
                cols: place_name, question_type, response, response_bi (0/1),
                      identity, identity2, identity3


================================================================================
END OF INSTRUCTIONS
================================================================================
